import java.util.*;

/**
 * @author Jimmy Zhan WORKSTATION
 * @since 2023/8/30 20:17
 * 说明：
 */

public class TeamRanking {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();

        Map<String, Team> teamMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String rankings = scanner.nextLine();

            for (int j = 0; j < rankings.length(); j++) {
                String teamName = String.valueOf(rankings.charAt(j));

                if (!teamMap.containsKey(teamName)) {
                    teamMap.put(teamName, new Team(teamName));
                }

                Team team = teamMap.get(teamName);
                team.updateRanking(j+1);
            }
        }

        List<Team> teamList = new ArrayList<>(teamMap.values());
        Collections.sort(teamList);

        for (Team team: teamList) {
            System.out.print(team.getName());
        }
    }
}

class Team implements Comparable<Team> {
    private String name;
    private int bestRank;
    private Map<Integer, Integer> rankCount;

    public Team(String name) {
        this.name = name;
        this.bestRank = Integer.MAX_VALUE;
        this.rankCount = new HashMap<>();
    }

    public String getName(){
        return name;
    }

    public void updateRanking(int rank) {
        bestRank = Math.min(bestRank, rank);
        rankCount.put(rank, rankCount.getOrDefault(rank, 0) + 1);
    }

    public int compareTo(Team other) {
        if (this.bestRank != other.bestRank) {
            return Integer.compare(this.bestRank, other.bestRank);
        } else {
            for (int i = 1; i <= 26; i++) {
                int thisCount = this.rankCount.getOrDefault(i, 0);
                int otherCount = other.rankCount.getOrDefault(i, 0);
                if (thisCount != otherCount) {
                    return Integer.compare(otherCount, thisCount);
                }
            }
            return this.name.compareTo(other.name);
        }
    }
}
















